import React from 'react'
import {
  increment,
  decrement,
  addValue,
  syncAddvalue
} from "../../store/modules/counterSlice";
import { useSelector, useDispatch } from "react-redux";

export default function Name() {
    // 获取仓库数据
    const count = useSelector(state => state.counter.value);
    // 获取修改仓库数据的工具
    const dispatch = useDispatch();
  return (
    <div>
    <p>
      仓库数据：{count}
    </p>
    <button onClick={() => dispatch(increment())}>+1</button>
    <button onClick={() => dispatch(decrement())}>-1</button>
    <button onClick={() => dispatch(addValue(5))}>+5</button>
    <button onClick={() => dispatch(syncAddvalue(10))}>两秒后+10</button>
    <button onClick={() => dispatch(syncAddvalue(100))}>变成100</button>
  </div>

  )
}
